package com.example.demo.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Document;
import com.example.demo.vo.documentDetailVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DocumentMapper extends BaseMapper<Document> {

    @Select("select url from document where user_id=#{userId}")
    List<String> getUrl(@Param("userId") Long userId);

    @Update("update document set is_embedding=1 where user_id=#{userId}")
    void setEmbedding(@Param("userId") Long userId);

    @Select("select * from document where user_id=#{userId}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "url", column = "url"),
            @Result(property = "title", column = "title"),
            @Result(property = "isEmbedding", column = "is_embedding"),
            @Result(property = "createdAt", column = "created_at")
    })
    List<documentDetailVO> getDocumentDetail(@Param("userId") Long userId);

}
